<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="来电电话">
              <j-input placeholder="请输入来电电话" v-model="queryParam.phone"></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="来电日期">
<!--              <a-input placeholder="请输入来电日期" v-model="queryParam.callTime"></a-input>-->
              <a-date-picker v-model="queryParam.callTime" format='YYYY-MM-DD HH:mm:ss' showTime @change="stringify" style="width: 100%"/>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <!-- <a-form-item label="进店日期">
              <j-input placeholder="请输入进店日期" v-model="queryParam.salesName"></j-input>
            </a-form-item>-->
            <a-form-item label="来电姓名">
              <j-input placeholder="请输入来电姓名" v-model="queryParam.name"></j-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button
                type="primary"
                @click="searchReset"
                icon="reload"
                style="margin-left: 8px"
              >重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
<!--      <a-button @click="handleAdd" type="primary" icon="plus">客户进店登记</a-button>-->
      <!--      <a-button type="primary" icon="download" @click="handleExportXls('cxm-订单记录信息')">导出</a-button>-->
      <!--      <a-upload-->
      <!--        name="file"-->
      <!--        :showUploadList="false"-->
      <!--        :multiple="false"-->
      <!--        :headers="tokenHeader"-->
      <!--        :action="importExcelUrl"-->
      <!--        @change="handleImportExcel"-->
      <!--      >-->
      <!--        <a-button type="primary" icon="import">导入</a-button>-->
      <!--      </a-upload>-->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px">
          批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
<!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">-->
<!--        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择-->
<!--        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项-->
<!--        <a style="margin-left: 24px" @click="onClearSelected">清空</a>-->
<!--      </div>-->

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange"
        :scroll="{ x: 1200 }"
      >
        <span slot="action" slot-scope="text, record">
          <a-button @click="showModal(record,1)">查看</a-button>
          <a-button type="primary" v-if="record.status == '0'" @click="showModal(record,0)" style="margin-left: 10px;">修改</a-button>
<!--          <a-button @click="showModal(record)">作废</a-button>-->
          <a-modal v-model="visible2" title="作废提示" @ok="getInfo(recordInfo)">
            <p>是否对该条记录进行作废？作废后将无法恢复！</p>
          </a-modal>
        </span>


<!--        <span slot="enterpriseName" slot-scope="text, NetRecord">-->


<!--        </span>-->


        <span
          slot="filterDepositAttribute"
          slot-scope="powerType"
        >{{ powerType | filterDepositAttribute(powerType) }}</span>
      </a-table>
      <call-for-consultation-model ref="callForConsultationModel"></call-for-consultation-model>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
  </a-card>
</template>

<script>
import callForConsultationModel from './callForConsultationModel'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import JInput from '@comp/jeecg/JInput'
import moment from 'moment'
import { getAction } from '../../../api/manage'

export default {
  name: 'consultationList',
  mixins: [JeecgListMixin],
  components: {
    callForConsultationModel,
    JInput,
    moment
  },
  data() {
    return {
      description: 'cxm-订单管理页面',
      visible: false,
      visible2: false,
      record:'',
      NetRecord:'',
      // 表头
      loading: '',
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '来电姓名',
          align: 'center',
          width: 120,
          dataIndex: 'name',
        },
        {
          title: '来电电话',
          align: 'center',
          width: 140,
          dataIndex: 'phone'
        },
        {
          title: '来电日期',
          align: 'center',
          width: 180,
          dataIndex: 'callTime'
        },
        {
          title: '办理状态',
          align: 'center',
          width: 140,
          dataIndex: 'status',
          scopedSlots: {
            customRender: 'filterDepositAttribute',
          },
        },
        {
          title: '来电次数',
          align: 'center',
          width: 120,
          dataIndex: 'count'
        },
        {
          title: '企业名称',
          align: 'center',
          dataIndex: 'enterpriseName',
          sorter: true,
          // scopedSlots: { customRender: 'enterpriseName' },
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width: 240,
          fixed: 'right',
          scopedSlots: {
            customRender: 'action'
          }
        }
      ],

      url: {
        list: '/cxm/cxmCallInfo/list',
        delete: '/sale/cxmSaleIntention/delete',
        deleteBatch: '/sale/cxmSaleIntention/deleteBatch',
        exportXlsUrl: 'sale/cxmSaleIntentionexportXls',
        importExcelUrl: 'sale/cxmSaleIntentionimportExcel'
      },
      recordInfo: {}
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${process.env.VUE_APP_BASE_API}/${this.url.importExcelUrl}`
    }
  },
  created() {
    // console.log(this.dataSource)

  },
  methods: {
    stringify(e) {
      if (e) {
        this.queryParam.callTime = this.queryParam.callTime.format('YYYY-MM-DD HH:mm:ss')
      }
    },
    showModal(record,type) {
      console.log(record)
      this.$refs.callForConsultationModel.edit(record,type)
      // this.visible2 = true
      // this.recordInfo = record
    },


    refresh(){
      this.loadData()
    },

  },
  filters: {
    filterTime(time) {
      return moment(time).format('YYYY-MM-DD')
    },
    filterDepositAttribute(depositAttribute) {
      switch (depositAttribute) {
        case '0':
          return '未处理'
          break
        case '1':
          return '已处理'
          break
      }
    }
  }
}
</script>
<style scoped>

</style>
